// 导入二次封装axios
import koi from "@/utils/axios.ts";

// 统一管理接口
enum API {
  LIST = "/platform/merchant/merchant-category/list",
  GET_BY_ID = "/platform/merchant/merchant-category/getById",
  ADD = "/platform/merchant/merchant-category/add",
  UPDATE = "/platform/merchant/merchant-category/update",
  DELETE = "/platform/merchant/merchant-category/deleteById",
  BATCH_DELETE = "/platform/merchant/merchant-category/batchDelete",
  GET_DETAIL_BY_ID = "/platform/merchant/merchant-category/getDetailById",
  UPDATE_STATUS = "/platform/merchant/merchant-category/updateStatus",
  LIST_MENUIDS_BY_CATEGORY_ID = "/platform/merchant/merchant-category/listMenuIdsByCategoryId",
  LIST_NORMAL = "/platform/merchant/merchant-category/listNormal",
  SAVECATEGORYMENU = "/platform/merchant/merchant-category/saveCategoryMenu"
}

export const listPage = (params: any) => {
  return koi.get(API.LIST, params);
};

export const add = (params: any) => {
  return koi.post(API.ADD, params);
};

export const update = (params: any) => {
  return koi.post(API.UPDATE, params);
};

export const getById = (id: any) => {
  return koi.get(API.GET_BY_ID, { id });
};

export const deleteById = (id: any) => {
  return koi.post(API.DELETE, { id });
};

export const batchDelete = (ids: any) => {
  return koi.post(API.BATCH_DELETE, { ids }); // 第一种传参方式
};

export const getDetailById = (id: any) => {
  return koi.get(API.GET_DETAIL_BY_ID, { id });
};

export const listMenuIdsByCategoryId = (id: any) => {
  return koi.get(API.LIST_MENUIDS_BY_CATEGORY_ID, { id });
};

export const saveCategoryMenu = (categoryId: any, menuIds: any) => {
  return koi.post(API.SAVECATEGORYMENU, { categoryId, menuIds });
};

export const updateStatus = (id: any, status: any) => {
  return koi.post(API.UPDATE_STATUS, { id, status });
};
export function listNormal() {
  return koi.get(API.LIST_NORMAL);
}
